$(function () {
    userreg.init();
})
let userreg = {

    param: {
        degree: [
            {id: 1, value: "小学", select: true},
            {id: 2, value: "初中", select: false},
            {id: 3, value: "高中", select: false},
            {id: 4, value: "大学", select: false},
            {id: 5, value: "研究生", select: false}
        ],
        province: [
            {id: 1, value: "湖南省", select: false},
            {id: 2, value: "湖北省", select: false}
        ],
        city: {
            "湖南省": [
                {id: 1, value: "长沙市", select: false},
                {id: 2, value: "株洲市", select: false},
                {id: 3, value: "湘潭市", select: false},
                {id: 4, value: "衡阳市", select: false},
                {id: 5, value: "邵阳市", select: false},
                {id: 6, value: "岳阳市", select: false},
                {id: 7, value: "常德市", select: false},
                {id: 8, value: "张家界市", select: false},
                {id: 9, value: "益阳市", select: false},
                {id: 10, value: "郴州市", select: false},
                {id: 11, value: "永州市", select: false},
                {id: 12, value: "怀化市", select: false},
                {id: 13, value: "娄底市", select: false},
                {id: 14, value: "湘西土家族苗族自治州", select: false}
            ],
            "湖北省": [
                {id: 1, value: "武汉市", select: false},
                {id: 2, value: "黄石市", select: false},
                {id: 3, value: "襄阳市", select: false},
                {id: 4, value: "荆州市", select: false},
                {id: 5, value: "宜昌市", select: false},
                {id: 6, value: "十堰市", select: false},
                {id: 7, value: "孝感市", select: false},
                {id: 8, value: "荆门市", select: false},
                {id: 9, value: "鄂州市", select: false},
                {id: 10, value: "黄冈市", select: false},
                {id: 11, value: "咸宁市", select: false},
                {id: 12, value: "随州市", select: false},
                {id: 13, value: "恩施土家族苗族自治州", select: false}
            ],
        },
        user: {
            name: null,
            age: null,
            degree: null,
            p_address: null,
            c_address: null,
            sex: null,
            height: null,
            hobby: null,
            dream: null
        }
    },
    init: function () {
        userreg.layout.init();
        userreg.event.init();
        userreg.service.init();
    },
    layout: {
        init: function () {

            /*$("#name").css("background-color", "aqua") //document.getElementById("ID").style.background-color=aqua;*/
            /*$("#name").val("初始化为123");*/
            CommontUnit.initCheckBoxSelectAll("");
            CommontUnit.initRadioSelectByValue("1");
            CommontUnit.initSelectMethod("sel_province_address", userreg.param.province)
            //加载对应的省级地区


            /* $("#name").addClass("inputsty");*/


        }
    },
    event: {
        init: function () {
            $("#userFormSubmit").bind("click", function () {
                userreg.service.userregFormSubmit();
            })
            $("#sel_province_address").change(function () {
                let value = $("#sel_province_address").val();
                userreg.service.initProvince(value);
            })
        }
    },
    service: {
        init: function () {
            CommontUnit.initSelectMethod("sel_degree", userreg.param.degree);

        },
        initProvince: function (value) {
            let city_address_option = $("#sel_city_address option");
            userreg.check.isCityEmpty(city_address_option);
            CommontUnit.initSelectMethod("sel_city_address", userreg.param.city[value]);
        },
        userregFormSubmit: function () {
            let checkValues = CommontUnit.getCheckBoxValues("lovey");
            let param = CommontUnit.initFormDataToJson("userForm");
            CommontUnit.callBackMethod("http://localhost:8080/aaa", "post", param);

        }
    },
    check: {
        isCityEmpty: function (city_address_option) {
            if (city_address_option.length != 1) {
                city_address_option.not(":first").remove();
            }
        },
        checkName: function () {
            let $ch_name = $("#name");
        }
    },
    element: {
        obtainElement: function () {
            let $obtain_name = $("#name");
            let $obtain_age = $("#age");
            let $obtain_selDegree = $("#sel_degree");
            let $obtain_selProvinceAddress = $("#sel_province_address");
            let $obtain_selCityAddress = $("#sel_city_address");
            let $obtain_sex = $("input[type='radio'][value='" + values + "']");
            let $obtain_checkbox = $("input[type='checkbox'][name='" + name + "']");

        }
    }


}